﻿using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading.Tasks;
using log4net;
using Newtonsoft.Json;
using Quartz;
using TdxHq;
using TdxHq.Common;
using TdxHq.Invoker;

namespace TdxHq
{   
    [DisallowConcurrentExecution]
    public class QuoteChangeTask : IJob
    {

        private static readonly ILog Log = LogManager.GetLogger(typeof(QuoteChangeTask));
        public void Execute(IJobExecutionContext context)
        {
            int ic = SanpshootService.SnapshootQueue.Count;
            Console.WriteLine("cut:"+ ic);

            ConcurrentDictionary<string, QuoteRt> Snapshoot = new ConcurrentDictionary<string, QuoteRt>();
            for (int i = 0; i < ic; i++)
            {
                QuoteRt dd;
                var xx=SanpshootService.SnapshootQueue.TryDequeue(out dd);
                Snapshoot.AddOrUpdate(dd.StkCode, dd, (k, v) => dd);
            }
            RedisUtils.GetInstance().HqRedis.GetDatabase().Publish("all", JsonConvert.SerializeObject(Snapshoot));
            return;
        }

       
    }
}